#ifndef STATIC_VEC1D_H
#define STATIC_VEC1D_H
#include <cstring>
#include <cassert>
template <typename T, size_t sz>
struct svec1d
{
    using iter = T *;
    using const_iter = const T *;
    constexpr static size_t msize = sz;
    T elem[sz];
    svec1d() noexcept = default;

    svec1d(const svec1d &);
    svec1d &operator=(const svec1d &);
    inline svec1d &operator=(const T &);

    T &operator[](size_t n) noexcept { return elem[n]; }
    const T &operator[](size_t n) const noexcept { return elem[n]; }
    T &operator()(size_t n) noexcept { return elem[n]; }
    const T &operator()(size_t n) const noexcept { return elem[n]; }

    svec1d &operator+=(const svec1d &a);
    svec1d &operator-=(const svec1d &a);

    constexpr size_t size() const { return msize; }
    iter begin() { return elem; }
    const_iter begin() const { return elem; }
    iter end() { return elem + msize; }
    const_iter end() const { return elem + msize; }
};

template <typename T, size_t sz>
svec1d<T, sz>::svec1d(const svec1d &src)
{
    memcpy(elem, src.begin(), sizeof(T) * src.size());
}

template <typename T, size_t sz>
svec1d<T, sz> &svec1d<T, sz>::operator=(const svec1d &src)
{
    assert(msize == src.size());
    memcpy(elem, src.begin(), sizeof(T) * src.size());
    return *this;
}

template <typename T, size_t sz>
svec1d<T, sz> &svec1d<T, sz>::operator=(const T &n)
{
    for (int i = 0; i != msize; ++i)
        elem[i] = n;
    return *this;
}

template <typename T, size_t sz>
svec1d<T, sz> &svec1d<T, sz>::operator+=(const svec1d &a)
{
    for (size_t i = 0; i != sz; ++i)
        elem[i] += a[i];
    return *this;
}

template <typename T, size_t sz>
svec1d<T, sz> &svec1d<T, sz>::operator-=(const svec1d &a)
{
    for (size_t i = 0; i != sz; ++i)
        elem[i] -= a[i];
    return *this;
}

#endif